use std::collections::HashMap;
use serde::{Serialize, Deserialize};

/// 串口配置\
/// mapping 串口对应的详细配置
#[derive(Debug, Serialize, Deserialize)]
pub struct SerialConfig {
    pub mapping: HashMap<String, InnerSerialConfig>,
}

/// 串口的详细配置\
/// baud_rate 波特率\
/// parity 校验 0 none 1 odd 2 even\
/// rate_delay_sec 循环间隔 单位为秒\
/// exec_delay_sec 初始执行延时 单位为秒\
/// serial_timeout 串口超时\
/// read_delay_millis 读取单次延时\
/// reread_times 读取次数\
/// soil_address 土壤件的地址\
/// weather_address 天气件的地址\
/// sleet_address 雨雪件的地址
#[derive(Debug, Serialize, Deserialize)]
pub struct InnerSerialConfig {
    pub baud_rate: u32,
    pub parity: u32,
    pub data_bits: u32,
    pub stop_bits: u32,
    pub rate_delay_sec: u64,
    pub exec_delay_sec: u64,
    pub serial_timeout: u64,
    pub read_delay_millis: u64,
    pub reread_times: u64,
    pub soil_address: Vec<u32>,
    pub weather_address: Vec<u32>,
    pub sleet_address: Vec<u32>,
    pub switch_address: Vec<u32>,
    pub paralleling_address: Vec<String>,
}